package com.sanfu.etl.utils;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

// *********************
// ** @Date: 2021-06-17
// ** @Author: Camemax
// ** @Description: 数据流环境工具类
// *********************
@Scope
@Component
public class StreamEnvironmentUtils {

    private StreamEnvironmentUtils(){}

    public static StreamExecutionEnvironment getStreamEnv(){
        int cpuCores = Runtime.getRuntime().availableProcessors();
        return getStreamEnv(cpuCores);
    }

    public static StreamExecutionEnvironment getStreamEnv(int parallel){
        return StreamExecutionEnvironment.getExecutionEnvironment().setParallelism(parallel);
    }
}
